package com.czxy.dem01;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test17 {
    public static void main(String[] args) {

        Student s1=new Student("zhangsan",18,"男");
        Student s2=new Student("lihong",22,"女");
        Student s3=new Student("wangwu",19,"男");
        Student s4=new Student("wuwu",8,"女");
        Student s5=new Student("lilin",35,"男");

        List<Student> list=new ArrayList<Student>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);

        Map<String,Integer> map = new HashMap<>();
        int count1 = 0;
        int count2 = 0;
        for (Student student : list) {
            if (student.getSex().equals("男")) {
                count1++;
            }else {
                count2++;
            }
        }
        System.out.println("男（"+count1+")女("+count2+")");

        int count3 = 0;
        int count4 = 0;
        for (Student student : list) {
            if (student.getAge()>18) {
                count3++;
            }else {
                count4++;
            }
        }
        map.put("成年",count3);
        map.put("未成年",count4);
        System.out.println(map);
    }
}
